﻿using System.Collections.Generic;
using System.Linq;

namespace Comkarl.Web.Resources
{
    internal static class IEnumerableExtensions
    {
        internal static int LastRefIndex(this IEnumerable<ResourceReference> references, string search)
        {
            int index = 0;
            int lastIndex = -1;
            ResourceReference[] refArray = references.ToArray();

            foreach(ResourceReference reference in refArray)
            {
                if(refArray[index].RefId.Contains(search))
                {
                    lastIndex = index;
                }

                index++;
            }

            return lastIndex;
        }
    }
}